<?php
namespace App\Http\Controllers;

use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;

use App\Models;


class FileController extends Controller
{
    public function files(Request $request,$keyboard=null){
		
		if($keyboard){
			$files = Models\Files::with('user')->select('file_id','title','miaosu','path','user_id','num','created_at')->find($keyboard);
			//$files['user'] = $files->user;
			$fronts['files'] = $files;
			
			$tdk['title'] = $fronts['files']['title'].' 文件下载_编程手册_开发软件_常用工具 - 代码示例网';
			$tdk['keywords'] = $fronts['files']['title'] .' 文件下载，编程手册，开发软件，常用工具';
			$tdk['description'] = $fronts['files']['title'].' 代码示例网提供编程手册、开发软件、常用工具等电子书|压缩包等安装文件下载';
		
		} else {
			$tdk['title'] = '文件下载_编程手册_开发软件_常用工具 - 代码示例网';
			$tdk['keywords'] = '文件下载，编程手册，开发软件，常用工具';
			$tdk['description'] = '代码示例网提供编程手册、开发软件、常用工具等电子书|压缩包等安装文件下载';
			
			$fronts['files'] = Models\Files::select('file_id','title','miaosu','path','user_id','num','created_at')->orderByDesc('file_id')->simplePaginate(27);
		}
		
		$fronts['tdk'] = $tdk;
		$fronts['keyboard'] = $tagname??$keyboard;
		
		
		//热点缓存
		if (!Cache()->has('hotarts')) {
			$fronts['hotarts'] = Models\Art::select('art_id','title')->orderByDesc('view')->where([['is_state', '=', '0'],['is_del', '=', '1']])->limit(5)->get()->toArray();
			Cache()->set('hotarts',$fronts['hotarts'],3600);
		}
		$fronts['hotarts'] = Cache()->get('hotarts');
		
		
        return view('front/file/files',$fronts);
    }
	

}
